require('./PageSbControl.less');
import { Control, Route } from 'react-keeper';
import React,{Component} from 'react';
import Reflux from 'reflux';
import ReactMixin from 'react-mixin';
import SbInfo from '../../../components/shenbao/SbInfo';
import EngSelect from './../engselect'
import Actions from './Actions'
import Store from './Store';
import 'weui';
import { Tab,TabBarItem,TabBar,Page,Article,
  Panel,Footer,FooterText,FormCell,Toast,Toptips,
  PanelHeader,
  PanelBody,
  PanelFooter,
  MediaBox,
  MediaBoxHeader,
  MediaBoxBody,
  MediaBoxTitle,
  MediaBoxDescription,
  MediaBoxInfo,
  MediaBoxInfoMeta,
  Cells,
  Cell,
  CellHeader,
  CellBody,
  CellFooter,
  Flex,
  FlexItem,
  Grids
} from  'react-weui/build/packages'
import sstp from './../../../assets/icon/搜索.png';



class SbControl extends Component {
    constructor(props) {
      super(props);
      this.state = {
        actshow: false
      }
      this.goselecteng = this.goselecteng.bind(this);
      this.setSelectEng = this.setSelectEng.bind(this);
      this.myHome = this.myHome.bind(this);

    }

    goselecteng() {
      Control.go('/myyewu/engselect');
    }

    setSelectEng(obj) {
      console.log('返回');
      console.info(obj);
      Actions.setCurrentEng(obj);
    }


    myHome() {
      Control.go('/home');
    }

    render() {
      const t = this;
        return (
          <div className="page sbcontrol">
            <div>1</div>


            <Panel className="head-panel">
              <PanelFooter>
                <Cell access link onClick={e=>{
                    this.refs.engselect.getCurrentEng()
                }}>
                  <div style={{textAlign:'left',fontSize:'14',color:'#586C94',displsy:'-webkit-box',fontFamily:'monospace'}}>
                    {this.state.sbctl.currentEng.engName}
                  </div>
                  <CellBody/>
                  <CellFooter><h5>选择工程</h5></CellFooter>
                </Cell>
              </PanelFooter>
            </Panel>


            <SbInfo  jlls={this.state.sbctl.jlmap.get("设备安装")} />

            <SbInfo  jlls={this.state.sbctl.jlmap.get("隐蔽报验")}  />

            <SbInfo  jlls={this.state.sbctl.jlmap.get("竣工申请")}  />



            <EngSelect ref="engselect" onSelectEng={this.setSelectEng} currentEng={this.state.sbctl.currentEng}></EngSelect>
            <Toast icon="loading" show={this.state.showLoading}>加载中...</Toast>


            <Footer>

              <FooterText>Copyright &copy; 湖北升思科技股份有限公司</FooterText>
            </Footer>

          </div>
        );
    }


    componentWillMount() {
      Actions.initMode();
    }

    componentDidMount() {
      Actions.initJDJL();
    }


  shouldComponentUpdate(nextProps = {}, nextState = {}) {
    const thisProps = this.props || {},
      thisState = this.state.sbctl || {};

    if (Object.keys(thisProps).length !== Object.keys(nextProps).length ||
      Object.keys(thisState).length !== Object.keys(nextState).length) {
      return true;
    }

    for (const key in nextProps) {
      if (thisProps[key] !== nextProps[key] || !is(thisProps[key], nextProps[key])) {
        console.log(thisProps[key], nextProps[key]);
        return true;
      }
    }

    for (const key in nextState) {
      if (thisState[key] !== nextState[key] || !is(thisState[key], nextState[key])) {
        return true;
      }
    }

    return true;
  }



}

ReactMixin.onClass(SbControl, Reflux.connect(Store, 'sbctl'));

export default SbControl ;
